class RandomizedSet {
public:
    RandomizedSet() {
        std::srand(static_cast<unsigned int>(std::time(0)));
        vt.resize(2 * 1e5);
    }
    
    bool insert(int val) {
        auto it = mp.find(val);
        if(it != mp.end())  return false;
        vt[count] = make_pair(val, 1);
        mp[val] = count;
        ++count;
        return true;
    }
    
    bool remove(int val) {
        auto it = mp.find(val);
        if(it == mp.end() || !vt[it->second].second)  return false;
        
        vt[count].second = 0;
        mp.erase(val);
        return true;
    }
    
    int getRandom() {
        int ret;
        int tmp = rand() % mp.size();
        for(const auto& [val, _] : mp)
        {
            if(tmp-- == 0)
            {
                ret = val;
                break;
            }
        }
        return ret;
    }

private:
    int count = 0;
    vector<pair<int, int>> vt;
    unordered_map<int, int> mp;
};

/**
 * Your RandomizedSet object will be instantiated and called as such:
 * RandomizedSet* obj = new RandomizedSet();
 * bool param_1 = obj->insert(val);
 * bool param_2 = obj->remove(val);
 * int param_3 = obj->getRandom();
 */
